/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ControlSignals.java
 *
 * Created on 09.12.2011., 15.46.25
 */
package aor2.gui.cpu.signals;

import aor2.cpu.blockcontrol.ControlSignalSet;
import java.awt.Graphics;

/**
 * 
 * @author Moxi
 */
public class ControlSignals extends javax.swing.JPanel {

	private ControlSignalSet ctrlSet;

	/** Creates new form ControlSignals */
	public ControlSignals() {
		ctrlSet = ControlSignalSet.getInstance();
		initComponents();
		refreshTable();
	}

	public void refreshTable() {
		int cnt = table.getRowCount();
		for (int i = 0; i < cnt; i++) {
			String signalName = table.getValueAt(i, 0).toString();
			table.setValueAt(
					Boolean.toString(ctrlSet.get(signalName).isActive()), i, 1);
		}
	}

	@Override
	protected void paintComponent(Graphics g) {
		refreshTable();
		super.paintComponent(g);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jScrollPane1 = new javax.swing.JScrollPane();
		table = new javax.swing.JTable();
		jLabel1 = new javax.swing.JLabel();

		table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {
				{ "REGin", null }, { "REGout", null }, { "PCin", null },
				{ "PCout", null }, { "SPin", null }, { "SPout", null },
				{ "opsel", null }, { "mxMAR", null }, { "MARin", null },
				{ "MBRin", null }, { "M1MBRout", null }, { "M2MBRout", null },
				{ "IR0in", null }, { "IR1in", null }, { "IR2in", null },
				{ "IR0Lout", null }, { "IR1out", null }, { "IR2out", null },
				{ "Ain", null }, { "Aout", null }, { "Bin", null },
				{ "Bout", null }, { "ALUSHIFTout", null }, { "Xin", null },
				{ "Yin", null }, { "PSWin", null }, { "PSWout", null },
				{ "ldpsw", null }, { "ldpswl", null }, { "clpswi", null },
				{ "clpswt", null }, { "stpswi", null }, { "stpswt", null },
				{ "inc", null }, { "dec", null }, { "not", null },
				{ "asr", null }, { "shl", null }, { "trans", null },
				{ "sgnext", null }, { "sub", null }, { "add", null },
				{ "or", null }, { "nop", null }, { "read", null },
				{ "write", null }, { "G12", null }, { "G21", null },
				{ "ldprcod", null }, { "stprins", null }, { "stpradr", null },
				{ "clprcod", null }, { "clpradr", null }, { "clprirr", null },
				{ "clprinm", null }, { "clprins", null },
				{ "BRUNMSKout", null }, { "BRUMSKout", null },
				{ "IVTPout", null }, { "brop", null }, { "braadr1", null },
				{ "braadr2", null }, { "branch", null }, { "bruncnd", null },
				{ "brnotpom1", null }, { "brnotpom2", null },
				{ "bradr0", null }, { "bradr1", null }, { "brregdir2", null },
				{ "brimmed2", null }, { "brMOV", null }, { "breql", null },
				{ "brnotprekid", null }, { "brPRCOD", null },
				{ "brPRADR", null }, { "brPRINS", null }, { "brPRIMM", null },
				{ "brPRINM", null } }, new String[] { "Signal", "Vrednost" }) {
			Class[] types = new Class[] { java.lang.String.class,
					java.lang.String.class };
			boolean[] canEdit = new boolean[] { false, false };

			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		jScrollPane1.setViewportView(table);

		jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 12));
		jLabel1.setText("Kontrolni Signali");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGap(86, 86,
																		86)
																.addComponent(
																		jLabel1))
												.addGroup(
														layout.createSequentialGroup()
																.addContainerGap()
																.addComponent(
																		jScrollPane1,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		258,
																		javax.swing.GroupLayout.PREFERRED_SIZE)))
								.addContainerGap(
										javax.swing.GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addComponent(jLabel1)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
								.addComponent(jScrollPane1,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										320, Short.MAX_VALUE).addContainerGap()));
	}// </editor-fold>//GEN-END:initComponents
		// Variables declaration - do not modify//GEN-BEGIN:variables

	private javax.swing.JLabel jLabel1;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JTable table;
	// End of variables declaration//GEN-END:variables
}
